from time import time
import sys
sys.path.insert(0,'../..')
from rmpoly import rgens
try:
  from gmpy import mpz
  print 'using gmpy mpz'
except:
  mpz = int
  print 'using int'

# faster with int
mpz = int

try:
  n = int(sys.argv[1])
  bits_exp = int(sys.argv[2])
except:
  print '''prog n bits_exp
  p = (1+x+y+z+t)^n
  bench p*(p+1)
  '''
  sys.exit()

assert n < 2**bits_exp

# fateman benchmark
rp,t,z,y,x = rgens('t,z,y,x', bits_exp, mpz)
p1 = (1+x+y+z+t).miller_pow(n)
p2 = p1 + 1

t1 = time()
h = p1*p2
t2 = time()
print '%s p = (1+x+y+z+t)^%d;  p*(p+1) t=%.2f' %(sys.argv,n,t2 - t1)
#print h.coefficient(x**2*y*z)

